package com.theeviljames.coursework.sender;

import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.theeviljames.coursework.server.RadioServer;

public class Sender {

	public Sender(int delay, int period) {
		try {
			ServerSocket server = new ServerSocket(7777);
			ExecutorService pool = Executors.newCachedThreadPool();
			RadioServer radioServer = new RadioServer(delay, period);
			while(true){
				Socket client = server.accept();
				SenderTask task = new SenderTask(client, delay, period);
				pool.execute(task);
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Sender sender = new Sender(10000, 2000);
	}

}
